home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / pluginy Firefox / 8206 / 8206.xpi / content / rss / joint.js < prev    next >
Text File  |  2010-02-02  |  704b  |  31 lines

  1. WiseStampJoint.prototype = new Object();
  2. WiseStampJoint.prototype.call = WiseStampJoint_call;
  3.  
  4. function WiseStampJoint(expectedCalls, callback) {
  5.   this._expectedCalls = expectedCalls;
  6.  
  7.   this._results = []
  8.   this._calls = [];
  9.   for (var i=0; i<expectedCalls; i++) {
  10.     this._calls[i] = false;
  11.     this._results[i] = false;
  12.   };
  13.  
  14.   this._callback = callback;
  15.  
  16.   if (expectedCalls <= 0) {
  17.     this._callback.apply(null, this._results);
  18.   };
  19. }
  20.  
  21. function WiseStampJoint_call(index, value) {
  22.   if (!this._calls[index]) {
  23.     this._expectedCalls --;
  24.     this._calls[index] = true;
  25.     this._results[index] = value;
  26.   };
  27.  
  28.   if (this._expectedCalls <= 0) {
  29.     this._callback.apply(null, this._results);
  30.   };
  31. }